<template>
  <div class="app-container">
    <!-- Sidebar -->
    <div class="sidebar" :class="{ open: sidebarOpen }">
      <div class="sidebar-header">
        <h2 class="sidebar-title">
          <i class="fas fa-file-alt"></i>
          CollabSpace
        </h2>
      </div>
      <div class="sidebar-content">
        <!-- Collaboration Members Section -->
        <div class="members-section">
          <div class="members-header">
            <h3 class="members-title">
              <i class="fas fa-users"></i>
              空间成员
            </h3>
            <div class="member-count">{{ spaceMembers.length }}/5</div>
          </div>
          <div class="members-list">
            <div
              v-for="member in spaceMembers"
              :key="member.id"
              class="member-item"
              :class="{ online: member.isOnline }"
            >
              <div class="member-avatar" :style="{ backgroundColor: member.color }">
                {{ member.name.charAt(0).toUpperCase() }}
              </div>
              <div class="member-info">
                <div class="member-name">{{ member.name }}</div>
                <div class="member-status">
                  <span class="status-dot" :class="{ online: member.isOnline }"></span>
                  {{ member.isOnline ? '在线' : '离线' }}
                </div>
              </div>
              <div class="member-role">{{ member.role }}</div>
            </div>
          </div>
          <div class="members-actions">
            <button class="invite-button" @click="showInviteModal = true">
              <i class="fas fa-user-plus"></i>
              邀请成员
            </button>
            <button class="manage-button" @click="showMembersModal = true">
              <i class="fas fa-cog"></i>
              管理
            </button>
          </div>
        </div>

        <!-- 空间容量信息 -->
        <div class="space-capacity-section">
          <div class="capacity-header">
            <h3 class="capacity-title">
              <i class="fas fa-hdd"></i>
              空间容量
            </h3>
          </div>
          <div class="capacity-stats">
            <div class="stat-item">
              <div class="stat-label">已使用</div>
              <div class="stat-value">{{ spaceCapacity.used }}GB</div>
            </div>
            <div class="stat-item">
              <div class="stat-label">总容量</div>
              <div class="stat-value">{{ spaceCapacity.total }}GB</div>
            </div>
            <div class="stat-item">
              <div class="stat-label">剩余</div>
              <div class="stat-value">{{ spaceCapacity.remaining }}GB</div>
            </div>
          </div>
          <div class="capacity-progress">
            <div class="progress-bar">
              <div class="progress-fill" :style="{ width: capacityPercentage + '%' }"></div>
            </div>
            <div class="progress-text">{{ capacityPercentage }}% 已使用</div>
          </div>
        </div>
      </div>
    </div>

    <!-- 主内容 - 空间资源列表 -->
    <div class="main-content">
      <div class="resource-header">
        <h2 class="resource-title">
          <i class="fas fa-folder"></i>
          空间资源
        </h2>
        <div class="resource-actions">
          <a-button type="primary" @click="showUploadModal = true">
            <i class="fas fa-plus"></i>
            上传资源
          </a-button>
        </div>
      </div>

      <!-- 资源筛选 -->
      <div class="resource-filter">
        <a-row :gutter="16">
          <a-col :span="8">
            <a-select
              placeholder="资源类型"
              style="width: 100%"
              v-model:value="resourceFilter.type"
              allowClear
            >
              <a-select-option value="document">文档</a-select-option>
              <a-select-option value="image">图片</a-select-option>
              <a-select-option value="video">视频</a-select-option>
              <a-select-option value="audio">音频</a-select-option>
              <a-select-option value="other">其他</a-select-option>
            </a-select>
          </a-col>
          <a-col :span="8">
            <a-select
              placeholder="上传时间"
              style="width: 100%"
              v-model:value="resourceFilter.time"
              allowClear
            >
              <a-select-option value="today">今天</a-select-option>
              <a-select-option value="week">本周</a-select-option>
              <a-select-option value="month">本月</a-select-option>
              <a-select-option value="year">今年</a-select-option>
            </a-select>
          </a-col>
          <a-col :span="8">
            <a-input-search
              placeholder="搜索文件名"
              v-model:value="resourceFilter.search"
              @search="onResourceSearch"
            />
          </a-col>
        </a-row>
      </div>

      <!-- 资源网格视图 -->
      <div class="resource-grid">
        <a-row :gutter="[16, 16]">
          <a-col :span="6" v-for="resource in filteredResources" :key="resource.id">
            <div
              class="resource-card"
              @mouseenter="showActions(resource.id)"
              @mouseleave="hideActions(resource.id)"
            >
              <div class="resource-icon">
                <i class="fas fa-file-pdf" v-if="resource.type === 'pdf'"></i>
                <i
                  class="fas fa-file-word"
                  v-else-if="resource.type === 'doc' || resource.type === 'docx'"
                ></i>
                <i
                  class="fas fa-file-excel"
                  v-else-if="resource.type === 'xls' || resource.type === 'xlsx'"
                ></i>
                <i
                  class="fas fa-file-powerpoint"
                  v-else-if="resource.type === 'ppt' || resource.type === 'pptx'"
                ></i>
                <i class="fas fa-file-image" v-else-if="resource.type === 'image'"></i>
                <i class="fas fa-file-video" v-else-if="resource.type === 'video'"></i>
                <i class="fas fa-file-audio" v-else-if="resource.type === 'audio'"></i>
                <i class="fas fa-file" v-else></i>
              </div>
              <div class="resource-info">
                <div class="resource-name">{{ resource.name }}</div>
                <div class="resource-meta">
                  <span>{{ resource.size }}</span>
                  <span>{{ resource.uploadTime }}</span>
                </div>
              </div>
              <!-- 悬浮操作按钮 -->
              <div class="resource-actions-overlay" v-show="hoveredResourceId === resource.id">
                <a-button type="primary" size="small" @click="editResource(resource)">
                  <i class="fas fa-edit"></i>
                  编辑
                </a-button>
                <a-button type="primary" danger size="small" @click="deleteResource(resource)">
                  <i class="fas fa-trash"></i>
                  删除
                </a-button>
              </div>
            </div>
          </a-col>
        </a-row>
      </div>
    </div>

    <!-- Invite Member Modal  邀请成员-->
    <a-modal v-model:open="showInviteModal" title="邀请成员" :footer="null" width="500px">
      <a-form :model="inviteForm" layout="vertical">
        <a-form-item label="邮箱地址" required>
          <a-input v-model:value="inviteForm.email" placeholder="请输入邮箱地址" type="email" />
        </a-form-item>

        <a-form-item label="角色" required>
          <a-select v-model:value="inviteForm.role" placeholder="选择角色">
            <a-select-option value="editor">编辑者</a-select-option>
            <a-select-option value="viewer">查看者</a-select-option>
          </a-select>
        </a-form-item>

        <a-form-item label="个人消息">
          <a-textarea
            v-model:value="inviteForm.message"
            placeholder="添加个人消息（可选）"
            :rows="3"
          />
        </a-form-item>

        <div class="modal-actions">
          <a-button @click="showInviteModal = false">取消</a-button>
          <a-button type="primary" @click="inviteMember">发送邀请</a-button>
        </div>
      </a-form>
    </a-modal>

    <!-- Manage Members Modal  成员管理-->
    <a-modal v-model:open="showMembersModal" title="管理空间成员" :width="700" :footer="null">
      <div class="members-management">
        <div class="members-table">
          <div class="table-header">
            <div class="header-cell">成员</div>
            <div class="header-cell">角色</div>
            <div class="header-cell">状态</div>
            <div class="header-cell">操作</div>
          </div>
          <div v-for="member in spaceMembers" :key="member.id" class="table-row">
            <div class="table-cell member-cell">
              <div class="member-avatar" :style="{ backgroundColor: member.color }">
                {{ member.name.charAt(0).toUpperCase() }}
              </div>
              <div class="member-details">
                <div class="member-name">{{ member.name }}</div>
                <div class="member-email">{{ member.email }}</div>
              </div>
            </div>
            <div class="table-cell">
              <a-select
                v-model:value="member.role"
                size="small"
                style="width: 100px"
                @change="updateMemberRole(member.id, $event)"
              >
                <a-select-option value="Owner">所有者</a-select-option>
                <a-select-option value="Editor">编辑者</a-select-option>
                <a-select-option value="Viewer">查看者</a-select-option>
                <a-select-option value="Commenter">评论者</a-select-option>
              </a-select>
            </div>
            <div class="table-cell">
              <a-tag :color="member.isOnline ? 'green' : 'default'">
                {{ member.isOnline ? '在线' : '离线' }}
              </a-tag>
            </div>
            <div class="table-cell">
              <a-button
                v-if="member.role !== 'Owner'"
                type="text"
                danger
                size="small"
                @click="removeMember(member.id)"
              >
                移除
              </a-button>
            </div>
          </div>
        </div>
      </div>
    </a-modal>

    <!-- Upload Resource Modal 上传资源 -->
    <a-modal v-model:open="showUploadModal" title="上传资源" @ok="handleUploadOk" width="600px">
      <a-form :model="uploadForm" layout="vertical">
        <a-form-item label="资源名称" required>
          <a-input v-model:value="uploadForm.name" placeholder="请输入资源名称" />
        </a-form-item>
        <a-form-item label="资源描述">
          <a-textarea
            v-model:value="uploadForm.description"
            placeholder="请输入资源描述（可选）"
            :rows="3"
          />
        </a-form-item>
        <a-form-item label="上传文件">
          <a-upload-dragger
            name="file"
            :multiple="false"
            :before-upload="beforeUpload"
            :show-upload-list="false"
          >
            <p class="ant-upload-drag-icon">
              <i class="fas fa-cloud-upload-alt" style="font-size: 48px; color: #1890ff"></i>
            </p>
            <p class="ant-upload-text">点击或拖拽文件到此区域上传</p>
            <p class="ant-upload-hint">支持单个文件上传，文件大小不超过100MB</p>
          </a-upload-dragger>
        </a-form-item>
      </a-form>
    </a-modal>
  </div>
</template>

<script setup lang="ts">
import { ref, reactive, computed, onMounted, nextTick, onBeforeUnmount } from 'vue'
import 'quill/dist/quill.snow.css'
import { useLoginUserStore } from '@/store/user'
import { useRouter } from 'vue-router'
// Types
interface Document {
  id: string
  title: string
  icon: string
  lastEdited: string
  collaborators: number
  content: string
}

interface SpaceMember {
  id: string
  name: string
  email: string
  role: 'Owner' | 'Editor' | 'Viewer' | 'Commenter'
  isOnline: boolean
  color: string
  joinedAt: string
}

interface InviteForm {
  email: string
  role: string
  message: string
}

// Reactive data
const sidebarOpen = ref(false)
const activeDocumentId = ref<string | null>(null)
const loginUser = useLoginUserStore()

// Members related data
const showInviteModal = ref(false)
const showMembersModal = ref(false)
const showUploadModal = ref(false)

// Space capacity data
const spaceCapacity = ref({
  used: 2.5,
  total: 10,
  remaining: 7.5,
})

// Resource related data
const hoveredResourceId = ref<string | null>(null)
const resourceFilter = reactive({
  type: '',
  time: '',
  search: '',
})

// Upload form data
const uploadForm = reactive({
  name: '',
  description: '',
  file: null,
})

// Sample resources data
const spaceResources = ref([
  {
    id: '1',
    name: '项目计划书.pdf',
    type: 'pdf',
    size: '2.5MB',
    uploadTime: '2024-01-15',
    description: '项目详细计划书',
  },
  {
    id: '2',
    name: '设计稿.psd',
    type: 'image',
    size: '15.2MB',
    uploadTime: '2024-01-14',
    description: '界面设计稿',
  },
  {
    id: '3',
    name: '演示视频.mp4',
    type: 'video',
    size: '45.8MB',
    uploadTime: '2024-01-13',
    description: '产品演示视频',
  },
  {
    id: '4',
    name: '数据分析.xlsx',
    type: 'xlsx',
    size: '1.2MB',
    uploadTime: '2024-01-12',
    description: '用户数据分析报告',
  },
  {
    id: '5',
    name: '会议记录.docx',
    type: 'docx',
    size: '0.8MB',
    uploadTime: '2024-01-11',
    description: '项目会议记录',
  },
  {
    id: '6',
    name: '原型图.sketch',
    type: 'other',
    size: '8.5MB',
    uploadTime: '2024-01-10',
    description: '交互原型图',
  },
])

const inviteForm = reactive<InviteForm>({
  email: '',
  role: 'editor',
  message: '',
})

// Space members data
const spaceMembers = ref<SpaceMember[]>([
  {
    id: '1',
    name: '张三',
    email: 'zhangsan@example.com',
    role: 'Owner',
    isOnline: true,
    color: '#3b82f6',
    joinedAt: '2024-01-01',
  },
  {
    id: '2',
    name: '李四',
    email: 'lisi@example.com',
    role: 'Editor',
    isOnline: true,
    color: '#ef4444',
    joinedAt: '2024-01-02',
  },
  {
    id: '3',
    name: '王五',
    email: 'wangwu@example.com',
    role: 'Viewer',
    isOnline: false,
    color: '#10b981',
    joinedAt: '2024-01-03',
  },
])

// Sample data
const documents = ref<Document[]>([
  {
    id: '1',
    title: '项目提案',
    icon: 'fas fa-file-code',
    lastEdited: '2小时前编辑',
    collaborators: 3,
    content: `<h1>项目提案：协作编辑平台</h1>
              <h2>执行摘要</h2>
              <p>我们提议开发一个先进的协作编辑平台，使多个用户能够实时协作。该平台将为文档创建、编辑和管理提供无缝体验，并具有强大的团队协作功能。</p>
              <h2>主要功能</h2>
              <ul>
                <li>具有冲突解决的实时协作编辑</li>
                <li>用户存在指示器和光标跟踪</li>
                <li>文档版本控制和历史记录</li>
                <li>富文本和代码编辑模式</li>
                <li>评论和标注系统</li>
                <li>基于角色的访问控制</li>
              </ul>
              <h2>技术实现</h2>
              <p>该平台将使用现代Web技术构建，包括用于前端的Next.js、用于实时通信的WebSocket以及用于数据持久化的强大数据库后端。</p>
              <h2>时间表</h2>
               <p>项目预计在六个月内分三个阶段完成，初步MVP交付在头两个月内。</p>`,
  },
  {
    id: '2',
    title: '会议记录',
    icon: 'fas fa-file-alt',
    lastEdited: '昨天编辑',
    collaborators: 1,
    content: '<h2>会议记录</h2><p>今天的会议讨论了项目进展和后续步骤...</p>',
  },
  {
    id: '3',
    title: 'API文档',
    icon: 'fas fa-file-code',
    lastEdited: '3天前编辑',
    collaborators: 2,
    content: '<h2>API文档</h2><p>REST API端点和用法示例...</p>',
  },
])

// Space capacity computed properties
const capacityPercentage = computed(() => {
  return Math.round((spaceCapacity.value.used / spaceCapacity.value.total) * 100)
})

// Filtered resources computed property
const filteredResources = computed(() => {
  let filtered = spaceResources.value

  // Filter by type
  if (resourceFilter.type) {
    filtered = filtered.filter((resource) => {
      if (resourceFilter.type === 'document') {
        return ['pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx'].includes(resource.type)
      }
      return resource.type === resourceFilter.type
    })
  }

  // Filter by search
  if (resourceFilter.search) {
    filtered = filtered.filter((resource) =>
      resource.name.toLowerCase().includes(resourceFilter.search.toLowerCase()),
    )
  }

  // Filter by time (simplified for demo)
  if (resourceFilter.time) {
    const today = new Date()
    filtered = filtered.filter((resource) => {
      const uploadDate = new Date(resource.uploadTime)
      const diffTime = Math.abs(today.getTime() - uploadDate.getTime())
      const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24))

      switch (resourceFilter.time) {
        case 'today':
          return diffDays <= 1
        case 'week':
          return diffDays <= 7
        case 'month':
          return diffDays <= 30
        case 'year':
          return diffDays <= 365
        default:
          return true
      }
    })
  }

  return filtered
})

// Members management methods
const inviteMember = () => {
  if (inviteForm.email && inviteForm.role) {
    const newMember: SpaceMember = {
      id: Date.now().toString(),
      name: inviteForm.email.split('@')[0],
      email: inviteForm.email,
      role: inviteForm.role as 'Owner' | 'Editor' | 'Viewer' | 'Commenter',
      isOnline: false,
      color: `#${Math.floor(Math.random() * 16777215).toString(16)}`,
      joinedAt: new Date().toISOString().split('T')[0],
    }
    spaceMembers.value.push(newMember)
    resetInviteForm()
    showInviteModal.value = false
  }
}

const resetInviteForm = () => {
  inviteForm.email = ''
  inviteForm.role = 'editor'
  inviteForm.message = ''
}

const updateMemberRole = (memberId: string, newRole: string) => {
  const member = spaceMembers.value.find((m) => m.id === memberId)
  if (member) {
    member.role = newRole as 'Owner' | 'Editor' | 'Viewer' | 'Commenter'
  }
}

const removeMember = (memberId: string) => {
  if (confirm('确定要移除此成员吗？')) {
    const index = spaceMembers.value.findIndex((m) => m.id === memberId)
    if (index !== -1) {
      spaceMembers.value.splice(index, 1)
    }
  }
}

// Resource related methods
const showActions = (resourceId: string) => {
  hoveredResourceId.value = resourceId
}

const hideActions = (resourceId: string) => {
  hoveredResourceId.value = null
}

const onResourceSearch = (value: string) => {
  resourceFilter.search = value
}
const router = useRouter()
const editResource = (resource: any) => {
  console.log('编辑资源:', resource)
  // 这里可以打开编辑模态框或跳转到编辑页面
  router.push('/teacher/collaborative_edit')
}

const deleteResource = (resource: any) => {
  if (confirm(`确定要删除资源 "${resource.name}" 吗？`)) {
    const index = spaceResources.value.findIndex((r) => r.id === resource.id)
    if (index !== -1) {
      spaceResources.value.splice(index, 1)
      console.log('已删除资源:', resource.name)
    }
  }
}

// Upload related methods
const beforeUpload = (file: File) => {
  const isLt100M = file.size / 1024 / 1024 < 100
  if (!isLt100M) {
    console.error('文件大小不能超过 100MB!')
    return false
  }
  uploadForm.file = file
  if (!uploadForm.name) {
    uploadForm.name = file.name
  }
  return false // 阻止自动上传
}

const handleUploadOk = () => {
  if (!uploadForm.name || !uploadForm.file) {
    console.error('请填写资源名称并选择文件')
    return
  }

  // 模拟上传
  const newResource = {
    id: Date.now().toString(),
    name: uploadForm.name,
    type: getFileType(uploadForm.file.name),
    size: formatFileSize(uploadForm.file.size),
    uploadTime: new Date().toISOString().split('T')[0],
    description: uploadForm.description,
  }

  spaceResources.value.unshift(newResource)

  // 更新容量使用
  const fileSizeGB = uploadForm.file.size / (1024 * 1024 * 1024)
  spaceCapacity.value.used += fileSizeGB
  spaceCapacity.value.remaining -= fileSizeGB

  // 重置表单
  uploadForm.name = ''
  uploadForm.description = ''
  uploadForm.file = null
  showUploadModal.value = false

  console.log('资源上传成功:', newResource.name)
}

const getFileType = (filename: string) => {
  const ext = filename.split('.').pop()?.toLowerCase()
  const typeMap: Record<string, string> = {
    pdf: 'pdf',
    doc: 'doc',
    docx: 'docx',
    xls: 'xls',
    xlsx: 'xlsx',
    ppt: 'ppt',
    pptx: 'pptx',
    jpg: 'image',
    jpeg: 'image',
    png: 'image',
    gif: 'image',
    mp4: 'video',
    avi: 'video',
    mov: 'video',
    mp3: 'audio',
    wav: 'audio',
  }
  return typeMap[ext || ''] || 'other'
}

const formatFileSize = (bytes: number) => {
  if (bytes === 0) return '0 B'
  const k = 1024
  const sizes = ['B', 'KB', 'MB', 'GB']
  const i = Math.floor(Math.log(bytes) / Math.log(k))
  return parseFloat((bytes / Math.pow(k, i)).toFixed(1)) + ' ' + sizes[i]
}
</script>

<style scoped>
:root {
  --background: #ffffff;
  --foreground: #09090b;
  --card: #ffffff;
  --card-foreground: #09090b;
  --popover: #ffffff;
  --popover-foreground: #09090b;
  --primary: #18181b;
  --primary-foreground: #fafafa;
  --secondary: #f4f4f5;
  --secondary-foreground: #18181b;
  --muted: #f4f4f5;
  --muted-foreground: #71717a;
  --accent: #f4f4f5;
  --accent-foreground: #18181b;
  --destructive: #ef4444;
  --destructive-foreground: #fafafa;
  --border: #e4e4e7;
  --input: #e4e4e7;
  --ring: #18181b;
  --radius: 0.5rem;
  --sidebar-background: #ffffff;
  --sidebar-foreground: #09090b;
  --sidebar-primary: #18181b;
  --sidebar-primary-foreground: #fafafa;
  --sidebar-accent: #f4f4f5;
  --sidebar-accent-foreground: #18181b;
  --sidebar-border: #e4e4e7;
  --sidebar-ring: #18181b;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.app-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
  font-family: 'Inter', sans-serif;
  background-color: var(--background);
  color: var(--foreground);
  line-height: 1.6;
}

/* Sidebar Styles */
.sidebar {
  width: 300px;
  background-color: var(--sidebar-background);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-title {
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.8rem;
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.document-item:hover .document-actions {
  opacity: 1;
}

/* Members Section Styles */
.members-section {
  margin-bottom: 2rem;
  padding: 1rem;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-radius: 0.75rem;
  border: 1px solid #e2e8f0;
}

.members-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.members-title {
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #1e293b;
}

.member-count {
  font-size: 0.875rem;
  color: #64748b;
  background: #ffffff;
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
  border: 1px solid #cbd5e1;
}

.members-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.member-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: #ffffff;
  border-radius: 0.5rem;
  border: 1px solid #e2e8f0;
  transition: all 0.2s;
}

.member-item:hover {
  border-color: #3b82f6;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
}

.member-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 0.875rem;
}

.member-info {
  flex: 1;
}

.member-name {
  font-weight: 500;
  font-size: 0.875rem;
}

.member-status {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  color: #64748b;
}

.status-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: #94a3b8;
}

.status-dot.online {
  background: #10b981;
}

.member-role {
  font-size: 0.75rem;
  color: #64748b;
  background: #f1f5f9;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
}

.members-actions {
  display: flex;
  gap: 0.5rem;
}

.invite-button,
.manage-button {
  flex: 1;
  padding: 0.5rem;
  border-radius: 0.5rem;
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #374151;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
}

.invite-button:hover,
.manage-button:hover {
  background: #f9fafb;
  border-color: #3b82f6;
  color: #3b82f6;
}

/* Members Management Modal Styles */
.members-management {
  max-height: 400px;
  overflow-y: auto;
}

.members-table {
  width: 100%;
}

.table-header {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 1rem;
  padding: 0.75rem;
  background: #f8fafc;
  border-radius: 0.5rem;
  margin-bottom: 0.5rem;
}

.header-cell {
  font-weight: 600;
  font-size: 0.875rem;
  color: #374151;
}

.table-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 1rem;
  padding: 0.75rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  margin-bottom: 0.5rem;
  align-items: center;
}

.table-cell {
  display: flex;
  align-items: center;
}

.member-cell {
  gap: 0.75rem;
}

.member-details {
  flex: 1;
}

.member-email {
  font-size: 0.75rem;
  color: #6b7280;
}

/* Modal styles */
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.share-section h4 {
  margin: 0 0 8px 0;
  font-size: 14px;
  font-weight: 600;
  color: #333;
}

.settings-section h4 {
  margin: 0 0 16px 0;
  font-size: 14px;
  font-weight: 600;
  color: #333;
  border-bottom: 1px solid #e9ecef;
  padding-bottom: 8px;
}

.setting-item label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: #333;
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    position: absolute;
    z-index: 100;
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .table-header,
  .table-row {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .header-cell {
    display: none;
  }

  .table-cell {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Quill Editor Overrides */
:deep(.ql-editor) {
  padding: 1.5rem;
  font-size: 1rem;
  line-height: 1.6;
}

:deep(.ql-editor h1) {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

:deep(.ql-editor h2) {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  margin-top: 1.5rem;
}

:deep(.ql-editor p) {
  margin-bottom: 1rem;
}

:deep(.ql-editor ul, .ql-editor ol) {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

:deep(.ql-editor li) {
  margin-bottom: 0.5rem;
}

/* Space Capacity Styles */
.space-capacity-section {
  margin-top: 24px;
  padding: 20px;
  background: #f8fafc;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
}

.capacity-header {
  margin-bottom: 16px;
}

.capacity-title {
  font-size: 16px;
  font-weight: 600;
  color: #1e293b;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.capacity-title i {
  color: #3b82f6;
}

.capacity-stats {
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
}

.stat-item {
  text-align: center;
  flex: 1;
}

.stat-label {
  font-size: 12px;
  color: #64748b;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 16px;
  font-weight: 600;
  color: #1e293b;
}

.capacity-progress {
  margin-top: 12px;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #1d4ed8);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 12px;
  color: #64748b;
  text-align: center;
  margin-top: 8px;
}

/* Resource Styles */
.main-content {
  flex: 1;
  padding: 24px;
  background: #ffffff;
  overflow-y: auto;
}

.resource-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e2e8f0;
}

.resource-title {
  font-size: 24px;
  font-weight: 600;
  color: #1e293b;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.resource-title i {
  color: #3b82f6;
}

.resource-filter {
  margin-bottom: 24px;
  padding: 20px;
  background: #f8fafc;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
}

.resource-grid {
  min-height: 400px;
}

.resource-card {
  position: relative;
  padding: 20px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #ffffff;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.resource-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 25px rgba(59, 130, 246, 0.15);
  border-color: #3b82f6;
}

.resource-icon {
  font-size: 48px;
  text-align: center;
  margin-bottom: 16px;
  color: #3b82f6;
  transition: transform 0.2s ease;
}

.resource-card:hover .resource-icon {
  transform: scale(1.1);
}

.resource-info {
  text-align: center;
}

.resource-name {
  font-size: 16px;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.resource-meta {
  font-size: 12px;
  color: #64748b;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.resource-actions-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  gap: 8px;
  background: rgba(255, 255, 255, 0.95);
  padding: 12px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(4px);
}

.resource-actions-overlay .ant-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  height: 32px;
  padding: 0 12px;
}
</style>
